import { IsDefined, IsInt, IsNotEmpty, IsString, Length } from "class-validator";
import { BaseEntity } from "../BaseEntity";
import { TStatus } from "../../types/CommonType";
import { Model } from "sequelize";

export default class SysMenuEntity extends BaseEntity {
  public id?: number;

  @Length(2, 10)
  @IsString()
  @IsNotEmpty()
  @IsDefined()
  public menuName: string;

  @IsInt()
  @IsNotEmpty()
  @IsDefined()
  public parentId: number;

  @IsInt()
  @IsNotEmpty()
  @IsDefined()
  public orderNum: string;

  @IsString()
  public path: string;

  @IsString()
  public component: string;

  @IsString()
  public query: string;

  @IsString()
  public isFrame: string;

  @IsString()
  public isCache: string;

  @IsString()
  public menuType: string;

  @IsString()
  public visible: string;

  @IsString()
  @IsNotEmpty()
  @IsDefined()
  public status: TStatus;

  @IsString()
  public perms: string;

  @IsString()
  public icon: string;

  public static transform(plainObject: object): SysMenuEntity {
    return super.baseTransform(SysMenuEntity, plainObject);
  }
}

export interface IMenuModel extends Model<SysMenuEntity> {}
